package com.hongyu.smart.village.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hongyu.smart.village.R;
import com.hongyu.smart.village.model.response.MemberResp;
import com.hongyu.smart.village.ui.base.BaseAdapter;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MemberAdapter  extends BaseAdapter<MemberResp,MemberAdapter.ViewHolder> {
    public MemberAdapter(Context mContext, List<MemberResp> mList) {
        super(mContext, mList);
    }

    @Override
    protected ViewHolder getViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    public int getItemView() {
        return R.layout.itme_member;
    }


    @Override
    public void onBindHolder(ViewHolder holder, int position) {
        MemberResp bean = mList.get(position);
        holder.tvName.setText(bean.getLabel());
        holder.tvAge.setText(""+bean.getAge());
        holder.tvSex.setText(bean.getSex()==0?"女":"男");
        holder.tvIds.setText(bean.getIdNumber().substring(0,6)+"********"+bean.getIdNumber().substring(bean.getIdNumber().length()-4));

    }


    static class ViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.tv_sex)
        TextView tvSex;
        @BindView(R.id.tv_age)
        TextView tvAge;
        @BindView(R.id.tv_ids)
        TextView tvIds;


        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
